const { Article } = require('../../model/article')
const pagination = require('mongoose-sex-page')  //分页第三方插件


module.exports = async(req, res) => {
    req.app.locals.currentLink = 'article'
    const page = req.query.page
        //page: 当前页
        //size 每页的条数
        //display 客户端要显示的页码数量
        //.populate('author') 多集合联合查询，得到的是author的全部信息
    var articles = await pagination(Article).find().page(page).size(5).display(3).populate('author').exec()
        // res.send(articles)
    res.render('admin/article.art', {
        articles: articles
    })
}